﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IotWeek2Day9.Models
{
    /// <summary>
    /// 用枚举定义事项的状态
    /// </summary>
    public enum ItemStatus
    {
        待办,
        已办,
        正在办
    }

    public class Item
    {
        [Key]
        public int ItemId { get; set; }

        /// <summary>
        /// 事项编号
        /// </summary>
        [StringLength(20)]
        [Required]
        public string ItemNo { get; set; }

        /// <summary>
        /// 事项标题
        /// </summary>
        [StringLength(50)]
        [Required]
        public string Title { get; set; }

        /// <summary>
        /// 事项的状态
        /// </summary>
        public ItemStatus Status { get; set; } = ItemStatus.待办; //默认为 待办

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }    //值类型默认就是非空的


        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 事项描述
        /// </summary>
        [StringLength(200)]
        [Required]
        public string ItemDetail { get; set; }

        /// <summary>
        /// 关联人（复选框，可多选，存人名）
        /// </summary>
        public string Contact { get; set; }


        /// <summary>
        /// 当事人
        /// </summary>
        [ForeignKey("Emp")]
        public int EmpId { get; set; }

        /// <summary>
        /// 图片路径的字段
        /// </summary>
        [StringLength(255)]
        public string FilePath { get; set; }

        //导航属性
        public Emp Emp { get; set; }

    }
}
